package gui;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;

import controller.FileController;

public class ToolBar extends JPanel implements ActionListener {
	public ToolBar() {
		super();
		this.setLayout(new FlowLayout(FlowLayout.LEFT));
		for (String tool : funcs) {
			ToolBtn tempBtn = new ToolBtn(tool);
			this.add(tempBtn);
			tempBtn.addActionListener(this);
		}
	}

	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		ToolBtn temp = (ToolBtn) e.getSource();
		if (temp.getFunc() == funcs[0]) { // new
			FileController.getInstance().newFile();
		} else if (temp.getFunc() == funcs[1]) {
			FileController.getInstance().openFile();
		} else if (temp.getFunc() == funcs[2]) {
			FileController.getInstance().saveFile();
		} else if (temp.getFunc() == funcs[3]) {
			FileController.getInstance().saveAsFile();
		} else if (temp.getFunc() == funcs[4]) {
			
		} else if (temp.getFunc() == funcs[5]) {
			//TODO
		}
	}

	private static final String[] funcs = { "new", "open", "save", "save as",
			"analysis", "plot"};

}
